<#include "/template/_ListPageWithTree.html" />
<#assign left_title="部门树"> 
<#assign center_title="部门职位列表">

<@left>
<ul id="lefttree" class="easyui-tree" url="${root!}/framedept/leftTree"></ul>
<script type="text/javascript">
			$(function(){
				$('#lefttree').tree({
					onClick:function(node){
						if(node.attributes.isreal=='1'){
							$('#dg').datagrid({
								url:'${root!}/frameduty/table?id='+node.id
							});
							$('#c_deptname').html(node.text);
							$('#c_deptId').val(node.id);
						}else{
							Alert.info('选择的为非真实部门','系统提示');
						}
					}
				});
			});
</script>
</@left> 
<@center>
<div id="tb" style="height:auto">
	<form id="ff" action="${root!}/frameduty/save">
	<div>
		<input id="c_deptId" type="hidden" name="frameduty.deptId" />
		当前部门：<span id="c_deptname" style="color:red;">空</span> | 职位名称：<input type="text" name="frameduty.dutyName" data-options="required:true"></input>
		排序号：<input class="easyui-numberbox" name="frameduty.order" value="0" required style="width: 50px;"/>  
		<@button id="tt" url="${root!}/frameduty/save" plain="true"
			text="保存" icon="save" formid="ff"
			oncomplete="afterSave(args);" />  
	</div>
	</form>
</div>
<@datatable id="dg" toolbar="#tb" fit="true" model="${root!}/frameduty/table" onLoadSuccess="tableSuccess">
	<@columns>
		<@column name="ck" checkbox="true" />
		<@column title='职位名称' name='dutyName' width="0.3" />
		<@column title='部门名称' name='deptName' width="0.3"/>
		<@column title='排序号' name='order' width="0.3"/>
		<@column title='操作' width="0.3" formatter="operate" />
		<@column name="id" hidden="true" /> 
	</@columns>
</@datatable>
<script type="text/javascript">

function afterSave(args){
	Alert.info(args,'系统提示',function(){
		var node = $('#lefttree').tree('getSelected');
		$('#dg').datagrid({
			url:'${root!}/frameduty/table?id='+node.id
		});
	});
}

function operate(val,row){
	return '<a class="deleteBtn" href="${root!}/frameduty/delete?id='+row.id+'" >删除</a>';
}

function tableSuccess(){
	$('.deleteBtn').each(function(){
		$(this).linkbutton({  
		    iconCls: 'icon-cancel',
		    plain:true
		});
	});
}

</script>
</@center>
